<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title> 智慧生活 | 登录</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="${rc.contextPath}/static/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="${rc.contextPath}/static/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="${rc.contextPath}/static/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="${rc.contextPath}/static/dist/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="${rc.contextPath}/static/plugins/iCheck/square/blue.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<style>
    html, body {
        height: auto;
    }

    /* .back_ground {
         background: url('../static/background/bg.jpg') repeat center center;;
     }*/
</style>
<body class="hold-transition login-page ">
<div class="login-box">
    <div class="login-logo">
        <a href="../../index2.html"><b>智慧</b>生活</a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">请登录</p>

        <form id="form" method="post">
            <div class="form-group has-feedback">
                <input type="text" id="username" class="form-control" placeholder="请输入用户名" name="username">
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <span id="username_warn" style="color: red;display: none;">用户名不能为空</span>
            <div class="form-group has-feedback">
                <input type="password" id="password" class="form-control" placeholder="请输入密码" name="password">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <span id="password_warn" style="color: red;display: none;">密码不能为空</span>
            <div class="row">
                <div class="col-xs-8">
                    <div class="checkbox icheck">
                        <label>
                            <input type="checkbox"> 记住我
                        </label>
                    </div>
                </div>
                <!-- /.col -->
                <div class="col-xs-4">
                    <button type="button" id="submitId" class="btn btn-primary btn-block btn-flat">登录</button>
                </div>
                <span id="login_warn" style="color: red;display: none;">用户名或者密码不能为空</span>
            </div>
        </form>

    </div>
    <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 2.2.3 -->
<script src="${rc.contextPath}/static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="${rc.contextPath}/static/bootstrap/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="${rc.contextPath}/static/plugins/iCheck/icheck.min.js"></script>
<script>
    $(function () {
        $("#submitId").click(function () {
            var username = $("#username").val();
            var password = $("#password").val();
            var pass = true;
            if (username.length == 0) {
                pass = false;
                $("#username_warn").show();
            } else {
                $("#username_warn").hide();
            }
            if (password.length == 0) {
                pass = false;
                $("#password_warn").show();
            } else {
                $("#password_warn").hide();
            }
            if (pass) {
                $.ajax({
                    url: "${rc.contextPath}/login/check",
                    type: "post",

                    data: {"username": username, "password": password},
                    success: function (data) {
                        if (data == "login_success") {
                            window.location.href = "${rc.contextPath}/home";
                        } else {
                            $("#login_warn").show();
                        }
                    }
                });
            }

        });
    });
</script>
</body>
</html>
